package com.example.sfm.controller;

import com.example.sfm.constant.MessageConstants;
import com.example.sfm.pojo.dto.AnnouncementQueryDto;
import com.example.sfm.result.PageResult;
import com.example.sfm.result.Result;
import com.example.sfm.service.IAnnouncementsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author sfm
 * @since 2025-03-07
 */
@RestController("userAnnouncementsController")
@RequestMapping("/user/announcements")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "用户端公告相关接口", description = "用户端公告相关接口")
public class AnnouncementsController {

    private final IAnnouncementsService announcementService;

    @Operation(summary = "获取所有公告", description = "根据查询条件获取公告列表")
    @GetMapping("/list")
    public Result<PageResult<?>> listAnnouncements(@ParameterObject AnnouncementQueryDto queryDto) {
        log.info("用户获取公告列表");
        return Result.success(announcementService.listAnnouncements(queryDto), MessageConstants.SELECT_OK);
    }
}